import { createSlice, PayloadAction } from "@reduxjs/toolkit"
import type { ErrorStateType } from "./type"

// 初始化数据
const INIT_STATE: ErrorStateType = {
    count: 0,
    errorInfoList: [],
    dateCount: 0
}

export const errorSlice = createSlice({
    name: "error",
    initialState: INIT_STATE,
    reducers: {
        // 加载数据（从数据库获取数据并存储）
        initErrorListReducer(state: ErrorStateType, action: PayloadAction<ErrorStateType>) {
            return action.payload
        }
    }
})

export const { initErrorListReducer } = errorSlice.actions
export default errorSlice.reducer
